﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace QLNSClient
{
    public partial class Frm_dsSAPTANGBACLUONG : DevExpress.XtraEditors.XtraForm
    {
        QLNSServiceReference.QLNSServiceClient sv = new QLNSServiceReference.QLNSServiceClient();
        
        public Frm_dsSAPTANGBACLUONG()
        {
            InitializeComponent();
        }

        public void LoadData()
        {
            gv_dsSAPTANGBL.DataSource = sv.getSLL();
            gridView1.Columns[0].Caption = "Mã cán bộ";
            gridView1.Columns[1].Caption = "Họ tên";
            gridView1.Columns[2].Caption = "Mã ngạch";
            gridView1.Columns[3].Caption = "Mã bậc";
            gridView1.Columns[4].Caption = "Ngày tăng bậc trước";

            if (gridView1.DataRowCount < 0)
            {
                MessageBox.Show("Chưa có dữ liệu!", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }

        private void Frm_dsSAPTANGBACLUONG_Load(object sender, EventArgs e)
        {
            LoadData();
        }


        private void qdTangBacLuong(object sender, EventArgs e)
        {
            splashScreenManager1.ShowWaitForm();
            Frm_CBNGACHLUONG frm = new Frm_CBNGACHLUONG();
            frm.updateDL = new Frm_CBNGACHLUONG.CapNhatDLCBNL(LoadData);
            frm.Show();
            splashScreenManager1.CloseWaitForm();
        }

        public static string sendMa_CB_CBSapTangNL;
        public static bool isSapTangBL = false;
        private void gridView1_PopupMenuShowing(object sender, DevExpress.XtraGrid.Views.Grid.PopupMenuShowingEventArgs e)
        {
            try
            {
                e.Menu.Items.Add(new DevExpress.Utils.Menu.DXMenuItem("Tăng bậc lương", qdTangBacLuong));
                sendMa_CB_CBSapTangNL = gridView1.GetFocusedRowCellDisplayText(gridView1.Columns[0]);
                isSapTangBL = true;
                FrmMain.isBLDauTien = false;
            }
            catch
            {
                MessageBox.Show("Bạn cần click vào dòng dữ liệu!", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
    }
}